%% Structural VARs with Sign Restrictions
% by Jaromir Benes
%
% This tutorials describes the identification of structural VARs based on
% sign restrictions, or other, more general, types of underdetermined
% identifying assumptions.

%% How to Best Run This Tutorial?
%
% Each m-file in this tutorial is split into what is called "code sections"
% in Matlab. A code cell is a shorter block of code performing a specific
% task, separated from other code cells by a double percent sign, `%%`
% (usually with a title and brief introduction added). By default, the
% cells are visually separated from each other by a horizontal rule in the
% Matlab editor.
%
% Instead of running each m-file from the command window, or executing this
% `read_me_first` as a whole, do the following. Open one tutorial m-file in
% the Matlab editor. Arrange the editor window and the command window next
% to each other so that you can see both of them at the same time. Then run
% the m-file cell by cell. This will help you watch closely what exactly
% is going on.
%
% To execute one particular cell, place the cursor in that cell (the
% respective block of code will get highlighted), and select "Run Current
% Section" from a contextual menu (upon a right click on the mouse), or
% pressing a keyboard shortcut (which differ on different systems and
% Matlab versions). To learn more on code sections, search Matlab
% documentation for "code section".

%% Make Up Data for VAR Estimation
%
% In this file, we generate three random series, and call them `R`,
% `PI`, and `Y` (for interest rates, inflation, and output). The series
% will be used to estimate a SVAR with sign restrictions.

% edit make_up_data.m;
make_up_data;

%% Estimate Structural VARs with Generalised Sign Restrictions
%
% In this file, we show how to identify structural VARs based on sign
% restrictions, and other, more general, types of underdetermined
% restrictions.
%
% We estimate a simple reduced-form VAR model on made-up data. Defining a
% set of sign restrictions on various impulse responses to identify one
% particular shock, we randomly draw a given number of SVARs satisfying
% these restrictions. We then examine the impulse responses obtained from
% these SVARs.

% edit VAR_sign_restrict.m;
VAR_sign_restrict;

%% Publish Tutorial Files to PDFs
%
% The following commands can be used to create PDF versions of the tutorial
% files:

%{
    latex.publish('read_me_first.m',[],'evalCode=',false);
    latex.publish('make_up_data.m');
    latex.publish('VAR_sign_restrict.m');
%}
